package com.itheima.config;

import org.mybatis.spring.SqlSessionFactoryBean;
import org.mybatis.spring.mapper.MapperScannerConfigurer;
import org.springframework.context.annotation.Bean;

import javax.sql.DataSource;

public class MybatisConfig {

    @Bean
    private SqlSessionFactoryBean sqlSessionFactoryBean(DataSource dataSource){
        SqlSessionFactoryBean sessionFactoryBean =new SqlSessionFactoryBean();
        sessionFactoryBean.setDataSource(dataSource);
        sessionFactoryBean.setTypeAliasesPackage("com.itheima.domain");
        return sessionFactoryBean;
    }

    @Bean
    private MapperScannerConfigurer mapperScannerConfigurer(){
        MapperScannerConfigurer mc =new MapperScannerConfigurer();
        mc.setBasePackage("com.itheima.dao");
        return mc;
    }
}
